//盛⽔最多的容器
public class maxArea {
    public static void main(String[] args) {
        int[] height = {1,8,6,2,5,4,8,3,7};
        System.out.println(maxArea(height));
    }
    public static  int maxArea (int[] height) {
        int V = 0,maxV = 0;
        int left = 0, right = height.length - 1;
        while(left < right) {
            V = Math.min(height[left], height[right]) * (right - left);
            if(height[left] < height[right]) {
                left++;
            }else {
                right--;
            }
            if(V > maxV) {
                maxV = V;
            }
        }
        return maxV;
    }
    public static int maxArea1(int[] height) {
        int V = 0,maxV = 0;
        for (int i = 0; i < height.length; i++) {
            for (int j = height.length-1; j > 0; j--) {
                V = Math.min(height[i],height[j]) * (j-i);
                if(V > maxV) {
                    maxV = V;
                }
            }
        }
        return maxV;
    }
}
